﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace csharp_dhtmleditor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ArrayList lst1 = new ArrayList();
            lst1.Add(@"굴림");
            lst1.Add(@"굴림체");
            lst1.Add(@"돋움");
            lst1.Add(@"돋움체");
            lst1.Add(@"바탕");
            lst1.Add(@"바탕체");
            lst1.Add(@"궁서");
            lst1.Add(@"궁서체");
            lst1.Add(@"Arial");
            lst1.Add(@"Arial Black");
            lst1.Add(@"Comic Sans MS");
            lst1.Add(@"Courier New");
            lst1.Add(@"Georgia");
            lst1.Add(@"Impact");
            lst1.Add(@"Lucida Console");
            lst1.Add(@"Lucida Sans Unicode");
            lst1.Add(@"Microsoft Sans Serif");
            lst1.Add(@"Modern");
            lst1.Add(@"Palatino Linotype");
            lst1.Add(@"Roman");
            lst1.Add(@"Script");
            lst1.Add(@"Symbol");
            lst1.Add(@"Tahoma");
            lst1.Add(@"Teminal");
            lst1.Add(@"Times New Roman");
            lst1.Add(@"Trebuchet MS");
            lst1.Add(@"Verdana");
            lst1.Add(@"Webdings");
            lst1.Add(@"Wingdings");

            ArrayList lst2 = new ArrayList();
            for (int i = 1; i < 8; i++)
            {
                lst2.Add(i);
            }

            comboBox1.DataSource = lst1;
            comboBox2.DataSource = lst2;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFONTNAME);
            if (status == DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object fontName = (object)comboBox1.Text;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFONTNAME, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref fontName);
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFONTSIZE);
            if (status == DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object fontSize = (object)comboBox2.Text;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFONTSIZE, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref fontSize);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_BOLD);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_BOLD, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_ITALIC);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_ITALIC, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_UNDERLINE);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_UNDERLINE, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFORECOLOR);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                if (colorDialog1.ShowDialog() == DialogResult.OK)
                {
                    object c = (object)colorDialog1.Color;
                    axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETFORECOLOR, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref c);
                }
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_ORDERLIST);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_ORDERLIST, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_UNORDERLIST);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_UNORDERLIST, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_INDENT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_INDENT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_OUTDENT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_OUTDENT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYLEFT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYLEFT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYCENTER);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYCENTER, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYRIGHT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_JUSTIFYRIGHT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref nvl);
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_HYPERLINK);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_HYPERLINK, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETBACKCOLOR);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                if (colorDialog1.ShowDialog() == DialogResult.OK)
                {
                    object c = (object)colorDialog1.Color;
                    axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SETBACKCOLOR, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref c);
                }
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_IMAGE);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_IMAGE, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }

        private void button15_Click(object sender, EventArgs e)
        {
            if (axDHTMLEdit1.DOM.selection.type != @"Control")
            {
                axDHTMLEdit1.DOM.selection.createRange().pasteHTML(@"<hr>");
            }
        }

        private void button16_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_CUT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_CUT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }

        private void button17_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_COPY);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_COPY, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }

        private void button18_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_PASTE);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_PASTE, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }

        private void button19_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_FONT);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_FONT, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, ref nvl);
            }
        }

        private void button20_Click(object sender, EventArgs e)
        {
            DHTMLEDLib.DHTMLEDITCMDF status = axDHTMLEdit1.QueryStatus(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SELECTALL);
            if (status >= DHTMLEDLib.DHTMLEDITCMDF.DECMDF_ENABLED)
            {
                object nvl = (object)IntPtr.Zero;
                axDHTMLEdit1.ExecCommand(DHTMLEDLib.DHTMLEDITCMDID.DECMD_SELECTALL, DHTMLEDLib.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref nvl);
            }
        }
    }
}
